package erlwitch.gui;

import java.awt.BorderLayout;

import ise.plugin.nav.Navigator;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;

import org.gjt.sp.jedit.EBComponent;
import org.gjt.sp.jedit.EBMessage;
import org.gjt.sp.jedit.View;

import erlwitch.parser.structure.Module;
import erlwitch.project.SourceFile;
import errorlist.DefaultErrorSource;

public class ErlwitchPanel extends JPanel implements EBComponent {

	private static final long serialVersionUID = 1L;
	
	private View view;
	private DefaultErrorSource source;
	private Navigator nav;

	private MainPanel main;
	private FunctionList flist;
	private JPanel buttons;

	public ErlwitchPanel(View view) {
		setLayout(new BorderLayout());
		buttons = new JPanel();
		add(buttons, BorderLayout.NORTH);
		
		flist = new FunctionList(view);
		main = new MainPanel(view);
		JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, main, flist);
		split.setOneTouchExpandable(true);
		add(split, BorderLayout.CENTER);
		split.setDividerLocation(0.5);
		instance = this;
	}
	
	public void handleMessage(EBMessage arg0) {
		System.out.println("Mensaje: " + arg0.getClass());
		arg0.notify();
	}
	
	public void back() {
		nav.goBack();
	}
	
	public void forth() {
		nav.goForward();
	}
	
	public void build() {
	}
	
	private static ErlwitchPanel instance;
	
	public static ErlwitchPanel getInstance() {
		return instance;
	}
	
	public void clearFunctionList() {
		flist.clear();
	}

	public void updateFunctionList(SourceFile srcFile) {
		flist.updateList(srcFile);
	}
}
